package com.netflexitysolutions.amazonws.s3.internal.operations;

import com.amazonaws.s3.doc._2006_03_01.DeleteObject;
import com.amazonaws.s3.doc._2006_03_01.Status;
import com.netflexitysolutions.amazonws.s3.S3;
import com.netflexitysolutions.amazonws.s3.S3ServerResponseStatus;

public class DeleteObjectOperation extends OperationExecutor<DeleteObject, S3ServerResponseStatus>{

    private String bucket;
    private String key;

    public DeleteObjectOperation(S3 s3, String bucket, String key){
        super(s3);
        this.bucket = bucket;
        this.key = key;
    }

    @Override
    protected S3ServerResponseStatus call(DeleteObject request) {
        request.setBucket(bucket);
        request.setKey(key);
        injectCredentials(request, "DeleteObject", getS3().getAccessKey(), getS3().getSecretKey());
        Status status = getS3().getService().deleteObject(request).getDeleteObjectResponse();
        return new S3ServerResponseStatus(status.getCode(), status.getDescription());
    }
}